package cn.javasea.atomikos.config;//package com.zhirui.lmwy.flow.config;
//
////import com.atomikos.icatch.jta.UserTransactionImp;
////import com.atomikos.icatch.jta.UserTransactionManager;
//
//import com.atomikos.icatch.jta.UserTransactionImp;
//import com.atomikos.icatch.jta.UserTransactionManager;
//import org.springframework.beans.factory.annotation.Qualifier;
//import org.springframework.boot.context.properties.ConfigurationProperties;
//import org.springframework.boot.jdbc.DataSourceBuilder;
//import org.springframework.boot.jta.atomikos.AtomikosDataSourceBean;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.context.annotation.Primary;
//import org.springframework.jdbc.core.JdbcTemplate;
//import org.springframework.transaction.jta.JtaTransactionManager;
//
//import javax.sql.DataSource;
//import javax.transaction.UserTransaction;
//
//@Configuration
//public class DatasourceConfig {
//
////    @Bean
////    @Primary
////    @ConfigurationProperties(prefix = "spring.datasource.ds1")
////    @Qualifier("ds1")
////    public DataSource activitiDataSource() {
////        DataSource build = DataSourceBuilder.create().build();
////        return build;
////    }
////
////    @Bean
////    @ConfigurationProperties(prefix = "spring.datasource.ds2")
////    @Qualifier("ds2")
////    public DataSource businessDataSource() {
////        DataSource build = DataSourceBuilder.create().build();
////        return build;
////    }
//
//    @Primary
//    @Bean(name = "ds1")
//    @Qualifier("ds1")
//    @ConfigurationProperties(prefix="spring.datasource.ds1")
//    public DataSource actDatasource() {
//        return new AtomikosDataSourceBean();
//    }
//
//    @Bean(name = "ds2")
//    @Qualifier("ds2")
//    @ConfigurationProperties(prefix="spring.datasource.ds2")
//    public DataSource businessDatasource() {
//        return new AtomikosDataSourceBean();
//    }
//
//    @Bean("jtaTransactionManager")
//    @Primary
//    public JtaTransactionManager activitiTransactionManager() {
//        UserTransactionManager userTransactionManager = new UserTransactionManager();
//        UserTransaction userTransaction = new UserTransactionImp();
//        return new JtaTransactionManager(userTransaction, userTransactionManager);
//    }
//
//    @Bean("jdbcTemplate1")
//    public JdbcTemplate jdbcTemplate1(@Qualifier("ds1") DataSource dataSource) {
//        return new JdbcTemplate(dataSource);
//    }
//
//    @Bean("jdbcTemplate2")
//    public JdbcTemplate jdbcTemplate2(@Qualifier("ds2") DataSource dataSource) {
//        return new JdbcTemplate(dataSource);
//    }
//}
